package com.gary.shiro.controller;

import ch.qos.logback.core.util.TimeUtil;
import com.gary.shiro.service.OrderService;
import io.micrometer.core.instrument.util.TimeUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author peng_rui
 * @date 2022/4/19
 */
@Slf4j
@RestController
@RequestMapping(value = "/api/gary/order")
public class OrderController {

    @Resource
    private OrderService orderService;

    @RequestMapping(value = "/buy", method = RequestMethod.GET)
    public String buy() {
        orderService.buy();
        return "success";
    }

    @RequestMapping(value = "/server", method = RequestMethod.GET)
    public String webClientServer() throws InterruptedException {
        log.info("我来了。。。。");
        log.info("do something...");
        Thread.sleep(1000);
        log.info("我走了");
        return "success";
    }

    @RequestMapping(value = "/add", method = RequestMethod.GET)
    public Integer add() {
        return orderService.add();
    }
}
